-
Notifications
You must be signed in to change notification settings - Fork 533
feat: add aggregate parameter input with presets #7146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add aggregate parameter input with presets #7146
Conversation
|
WalkthroughA new React component, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant BlueprintPlayground
participant ParameterInput
participant AggregateParameterInput
User->>BlueprintPlayground: Opens playground UI
BlueprintPlayground->>ParameterInput: Render input for parameter "aggregate"
ParameterInput->>AggregateParameterInput: Render with endpointPath and form field
AggregateParameterInput->>User: Shows input and preset dropdown
User->>AggregateParameterInput: Selects preset or enters value
AggregateParameterInput->>ParameterInput: Updates form value
ParameterInput->>BlueprintPlayground: Form value updated
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (8)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7146 +/- ##
=======================================
Coverage 55.68% 55.68%
=======================================
Files 904 904
Lines 58340 58340
Branches 4107 4107
=======================================
Hits 32484 32484
Misses 25751 25751
Partials 105 105
🚀 New features to boost your workflow:
|
size-limit report 📦
|
a1e9e1a
to
75d8e69
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
75d8e69
to
50f59b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🧹 Nitpick comments (3)
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx (1)
525-526
: Consider the impact of placeholder logic change.The placeholder logic has been simplified from a context-aware URL-based calculation to using
param.description || param.name
. While this works well for the aggregate parameter, it might reduce the user experience for path parameters where the original logic provided more meaningful placeholders like{param_name}
or:param_name
.Consider preserving the original placeholder logic for non-aggregate parameters:
- placeholder={param.description || param.name} + placeholder={param.name === "aggregate" ? (param.description || param.name) : (url.includes(`{${param.name}}`) ? `{${param.name}}` : url.includes(`:${param.name}`) ? `:${param.name}` : "Value")}Or extract the placeholder logic into a helper function for better maintainability.
apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx (2)
138-148
: Consider more flexible endpoint matching.The current exact string matching for endpoint paths is brittle and won't handle dynamic path segments or variations in endpoint structure.
Consider implementing more flexible pattern matching:
-const ENDPOINT_SPECIFIC_PRESETS: Record<string, Preset[]> = { - "/v1/transactions": GENERAL_TRANSACTIONS_PRESETS, - "/v1/wallets/{wallet_address}/transactions": WALLET_TRANSACTIONS_PRESETS, - "/v1/events": EVENTS_PRESETS, - "/v1/blocks": BLOCKS_PRESETS, - // Add more endpoint paths and their specific presets here -}; +const ENDPOINT_PATTERNS: Array<{pattern: RegExp, presets: Preset[]}> = [ + { pattern: /\/v1\/transactions$/, presets: GENERAL_TRANSACTIONS_PRESETS }, + { pattern: /\/v1\/wallets\/[^/]+\/transactions/, presets: WALLET_TRANSACTIONS_PRESETS }, + { pattern: /\/v1\/events/, presets: EVENTS_PRESETS }, + { pattern: /\/v1\/blocks/, presets: BLOCKS_PRESETS }, +]; function getAggregatePresets(endpointPath: string): Preset[] { - return ENDPOINT_SPECIFIC_PRESETS[endpointPath] || DEFAULT_AGGREGATE_PRESETS; + const match = ENDPOINT_PATTERNS.find(({pattern}) => pattern.test(endpointPath)); + return match?.presets || DEFAULT_AGGREGATE_PRESETS; }
180-186
: Consider edge case handling for preset selection.The current implementation only calls
onChange
whenselectedValue
is truthy, but consider what happens if a user wants to clear their selection.Consider adding a "Clear" option or handling empty selection:
onValueChange={(selectedValue) => { - if (selectedValue) { - onChange({ target: { value: selectedValue } }); - } + onChange({ target: { value: selectedValue || "" } }); }}Or add a clear option to the select dropdown.
🛑 Comments failed to post (1)
apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx (1)
19-37: 🛠️ Refactor suggestion
Improve default preset usability.
The default presets contain placeholder text like
your_field_here
which requires user modification. This might confuse users who expect working presets.Consider either:
- Removing the custom field presets from defaults and only including them in endpoint-specific collections where field names are known
- Adding clear documentation or help text indicating these are templates
const DEFAULT_AGGREGATE_PRESETS: Preset[] = [ { label: "Count All Items", value: "count() AS count_all" }, { label: "Sum (gas_used)", value: "sum(gas_used) AS total_gas_used" }, { label: "Average (gas_used)", value: "avg(gas_used) AS avg_gas_used" }, { label: "Min (gas_used)", value: "min(gas_used) AS min_gas_used" }, { label: "Max (gas_used)", value: "max(gas_used) AS max_gas_used" }, - // Presets for a user-defined field - { - label: "Count (custom field)", - value: "count(your_field_here) AS count_custom", - }, - { label: "Sum (custom field)", value: "sum(your_field_here) AS sum_custom" }, - { - label: "Average (custom field)", - value: "avg(your_field_here) AS avg_custom", - }, - { label: "Min (custom field)", value: "min(your_field_here) AS min_custom" }, - { label: "Max (custom field)", value: "max(your_field_here) AS max_custom" }, ];📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.const DEFAULT_AGGREGATE_PRESETS: Preset[] = [ { label: "Count All Items", value: "count() AS count_all" }, { label: "Sum (gas_used)", value: "sum(gas_used) AS total_gas_used" }, { label: "Average (gas_used)", value: "avg(gas_used) AS avg_gas_used" }, { label: "Min (gas_used)", value: "min(gas_used) AS min_gas_used" }, { label: "Max (gas_used)", value: "max(gas_used) AS max_gas_used" }, ];
🤖 Prompt for AI Agents
In apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx around lines 19 to 37, the default aggregate presets include placeholders like "your_field_here" which can confuse users expecting functional presets. To fix this, remove these custom field presets from the default list and instead include them only in endpoint-specific preset collections where actual field names are known, or alternatively add clear inline comments or UI help text indicating these presets are templates requiring user modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx
(1 hunks)apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx
[error] 454-454: This variable is unused.
Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
Unsafe fix: If this is intentional, prepend placeholder with an underscore.
(lint/correctness/noUnusedVariables)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Size
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx (4)
38-38
: LGTM!The import statement is correctly added for the new
AggregateParameterInput
component.
525-526
: LGTM!The placeholder change improves user experience by showing descriptive text, and the
endpointPath
prop enables the new aggregate parameter functionality.
591-591
: LGTM!The
endpointPath
prop is correctly added to the interface to support the new aggregate parameter functionality.
628-638
: LGTM!The conditional rendering for aggregate parameters is correctly implemented. All required props are passed to the
AggregateParameterInput
component, enabling the specialized functionality for aggregate parameter handling.
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx
Outdated
Show resolved
Hide resolved
50f59b3
to
548f0c3
Compare
548f0c3
to
72e77b2
Compare
Merge activity
|
<!-- start pr-codex --> ## PR-Codex overview This PR introduces the `AggregateParameterInput` component to handle aggregate parameters in the `BlueprintPlayground`. It adds new presets for various data types and modifies the `ParameterSection` to utilize this new component, enhancing the functionality of the parameter input system. ### Detailed summary - Added `AggregateParameterInput` component to handle aggregate parameters. - Introduced multiple preset options for aggregates, transactions, events, and blocks. - Updated `ParameterSection` to include a check for the `aggregate` parameter and render the new component. - Modified placeholder logic in `ParameterSection` to use `param.description` or `param.name`. - Passed `endpointPath` prop to `AggregateParameterInput` for context on preset selection. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a specialized input with preset selection for aggregate query parameters, enhancing usability when configuring aggregate values. - The playground UI now displays this new input component for aggregate parameters, providing relevant preset options based on the selected endpoint. - **Improvements** - Placeholders for parameter inputs now more accurately reflect the parameter’s description or name for better clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
72e77b2
to
9479d25
Compare
PR-Codex overview
This PR introduces the
AggregateParameterInput
component to handle aggregate parameter inputs in theBlueprintPlayground
. It adds functionality for selecting aggregate presets based on the endpoint path and refines the parameter section of the playground.Detailed summary
AggregateParameterInput
component inaggregate-parameter-input.client.tsx
.ParameterSection
to utilize the newAggregateParameterInput
when the parameter name is "aggregate".ParameterSection
to useparam.description
orparam.name
.endpointPath
prop toParameterInput
for better context handling.Summary by CodeRabbit